import Vue from 'vue'
import App from './App.vue'
import router from '@/route'
import Swiper from '@/components/Swiper'
import TypeNav from '@/components/TypeNav'
import store from './store'
import Pagination from '@/components/Pagination'

import { Button, Dialog, Message } from 'element-ui'
import VueLazyload from 'vue-lazyload'
import loading from '@/assets/loading.gif'
import VeeValidate from 'vee-validate'
import zh_CN from 'vee-validate/dist/locale/zh_CN'
import '@/mock'
Vue.use(VeeValidate)

VeeValidate.Validator.localize('zh_CN', {
  messages: {
    ...zh_CN.messages,
    regex: m => m + '输入的数据不符合规则'
  },
  attributes: {
    phone: '手机号',
    password: '密码',
    code: "验证码",
    passAgain: '确认密码',
    agree: '用户协议'
  }

})

VeeValidate.Validator.extend('agree', {
  validate: (value) => {
    if (value) return value
    else return value
  },
  getMessage: m => m + '必须同意',

})

Vue.use(VueLazyload, {
  loading
})
Vue.use(Dialog)
Vue.use(Button)
Vue.prototype.$message = Message

Vue.component('TypeNav', TypeNav);
Vue.component('Swiper', Swiper)
Vue.component('Pagination', Pagination)

Vue.config.productionTip = false

new Vue({
  render: h => h(App),
  store: store,
  router: router,
  beforeCreate() {
    Vue.prototype.$bus = this
  }

}).$mount('#app')
